package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.RoomBean;
import com.project.mapper.IRoomMapper;
import com.project.service.IRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class RoomServiceImpl implements IRoomService {

    @Autowired
    private IRoomMapper mapper;
    private static final int PAGESIZE=3;
    @Override
    public void addRoom(RoomBean roomBean) {
        mapper.addRoom(roomBean);
    }

    @Override
    public void delRoom(int id) {
        mapper.delRoom(id);
    }

    @Override
    public RoomBean findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public PageInfo<RoomBean> findByItem(int pageNo, String site, String canLive, String state, String type) {
        PageHelper.startPage(pageNo,PAGESIZE);
        PageInfo<RoomBean> info = PageInfo.of(mapper.findByItem(site, canLive, state, type));
        return info;
    }
}
